Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lib-dynamodb): input types conflicts with client-dynamodb #6676

Closed

Conversation

monholm
Copy link
Contributor

@monholm monholm commented Nov 19, 2024

Issue

Fixes #6668

Description

#6654 added | undefined to optional model props, but the types in lib-dynamodb wasn't updated to reflect that change. This leaves consumers using exactOptionalPropertyTypes: true with ts errors when trying to use almost any of the commands in lib-dynamodb.
E.g.:

import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, ScanCommand } from "@aws-sdk/lib-dynamodb";

const dyndbClient = new DynamoDBClient({});

const dyndbDocClient = DynamoDBDocumentClient.from(dyndbClient);

dyndbDocClient.send(new ScanCommand({ TableName: "my-table" }));

causes

Argument of type 'ScanCommand' is not assignable to parameter of type 'Command<ServiceInputTypes, ScanCommandInput, ServiceOutputTypes, ScanCommandOutput | ScanCommandOutput, SmithyResolvedConfiguration<...>>'.
  The types of 'middlewareStack.addRelativeTo' are incompatible between these types.
    Type '(middleware: MiddlewareType<ScanCommandInput | ScanCommandInput, ScanCommandOutput | ScanCommandOutput>, options: RelativeMiddlewareOptions) => void' is not assignable to type '(middleware: MiddlewareType<ScanCommandInput, ScanCommandOutput | ScanCommandOutput>, options: RelativeMiddlewareOptions) => void'.
      Types of parameters 'middleware' and 'middleware' are incompatible.
        Type 'MiddlewareType<ScanCommandInput, ScanCommandOutput | ScanCommandOutput>' is not assignable to type 'MiddlewareType<ScanCommandInput | ScanCommandInput, ScanCommandOutput | ScanCommandOutput>'.
          Type 'InitializeMiddleware<ScanCommandInput, ScanCommandOutput | ScanCommandOutput>' is not assignable to type 'MiddlewareType<ScanCommandInput | ScanCommandInput, ScanCommandOutput | ScanCommandOutput>'.
            Type 'InitializeMiddleware<ScanCommandInput, ScanCommandOutput | ScanCommandOutput>' is not assignable to type 'InitializeMiddleware<ScanCommandInput | ScanCommandInput, ScanCommandOutput | ScanCommandOutput>'.
              Type 'InitializeHandler<ScanCommandInput, ScanCommandOutput | ScanCommandOutput>' is not assignable to type 'InitializeHandler<ScanCommandInput | ScanCommandInput, ScanCommandOutput | ScanCommandOutput>'.
                Type 'ScanCommandInput | ScanCommandInput' is not assignable to type 'ScanCommandInput' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
                  Type 'import("/aws-sdk-error-repro/node_modules/@aws-sdk/client-dynamodb/dist-types/commands/ScanCommand").ScanCommandInput' is not assignable to type 'import("/aws-sdk-error-repro/node_modules/@aws-sdk/lib-dynamodb/dist-types/commands/ScanCommand").ScanCommandInput' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
                    Type 'ScanCommandInput' is not assignable to type '{ ScanFilter?: Record<string, Omit<Condition, "AttributeValueList"> & { AttributeValueList?: any[]; }>; ExclusiveStartKey?: Record<string, any>; ExpressionAttributeValues?: Record<...>; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
                      Types of property 'ScanFilter' are incompatible.
                        Type 'Record<string, Condition> | undefined' is not assignable to type 'Record<string, Omit<Condition, "AttributeValueList"> & { AttributeValueList?: any[]; }>'.
                          Type 'undefined' is not assignable to type 'Record<string, Omit<Condition, "AttributeValueList"> & { AttributeValueList?: any[]; }>'.

Testing

Enabled exactOptionalPropertyTypes in the aws-sdk repo while working on the issues, to ensure they got fixed.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

aws#6654 added `| undefined` to optional model props, but the types in lib-dynamodb wasn't updated to
reflect that change. This leaves consumers using `exactOptionalPropertyTypes: true` with ts errors
when trying to use almost any of the commands in lib-dynamodb

Fixes aws#6668
@monholm monholm requested a review from a team as a code owner November 19, 2024 17:05
@kuhe
Copy link
Contributor

kuhe commented Nov 20, 2024

moved to #6683 because I can't push to the fork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Library fails in typescript compilation with exactOptionalPropertyTypes=true
2 participants